package com.etc.demo;

import javax.xml.bind.annotation.XmlList;
import java.util.Arrays;

/**
 * @author: knowno
 * @create: 2024-09-05 10:11
 * @Version 1.0
 **/
public class TestSwap {

    public static void main(String[] args) {

        int x = 1, y = 2;
        swap(x, y);
        System.out.println("main: " + x + "," + y);
        System.out.println("**************");
        int arr[]={1,2,3};
        change(arr); //传递的arr=>值，实际上这个值是数组的首地址
        System.out.println("main : " + Arrays.toString(arr));
    }

    public static void swap(int x, int y) {

        int t = x;
        x = y;
        y = t;
        System.out.println("swap : " + x + "," + y);
    }

    public static void change(int x[]) {

        for (int i = 0; i < x.length; i++) {
            x[i] = x[i] * 2;
        }
        System.out.println("change : " + Arrays.toString(x));
    }
}
